///////////////////////////////////////////////////////////
//  CTemplateView.h
//  Implementation of the Class CTemplateView
//  Created on:      21-Sep-2013 9:37:06 AM
//  Original author: Jakkaphan Aiemcharoenjit
///////////////////////////////////////////////////////////

#if !defined(EA_B142F613_4F56_43ff_9FF4_E650ADAAFD88__INCLUDED_)
#define EA_B142F613_4F56_43ff_9FF4_E650ADAAFD88__INCLUDED_

#include "IViewCtrl.h"
#include "IPages.h"
#include "IWindowDirector.h"

using namespace Data;

namespace UI
{
class CTemplateView : public IViewCtrl
{

public:
  CTemplateView(IPages* templatePages, IWindowDirector* director);
	virtual ~CTemplateView();

	virtual IViewCtrl::ViewType GetType() const;
	virtual void Initialize();
	virtual void Refresh();
	virtual void ShowView(bool show = true);
	bool OnClickedNew(CButton* button);
	bool OnClickedEdit(CButton* button);
	void OnClickedNext();
	void OnSelectedTemplate();
	bool OnClickedView(CButton* button);
	bool OnClickedRemove(CButton* button);
	IPage* GetCurSelected();

  void AppendPage(IPage* newPage);
  void EditPage(IPage* newPage);

private:
  // Event handler
	bool OnClickedNavigationBar(CNavigationBar *naviBar, int button);
  bool OnClickedToolBar(CToolBar* toolBar, int button);
  bool OnSelectedTable(CTable* table, int tab);
  bool OnAlertButtonClick(CAlertDialog* dialog, EAlertDialogButton button);

	// Function
	CTableItemPtr CreateTemplateItem(IPage* page);

private:
	IViewCtrl::ViewType m_type;
	IWindowDirector*    m_parrentWnd;
	IPages*             m_templatePages;
	int                 m_currentRow;
  CNavigationBarPtr   m_navigationBar;
  CToolBarPtr         m_toolBar;
  CTablePtr           m_table;
  std::vector<CTableItemPtr> m_tableRows;
  CAlertDialogPtr     m_alretDlg;
};
}
#endif // !defined(EA_B142F613_4F56_43ff_9FF4_E650ADAAFD88__INCLUDED_)
